/*
 * Copyright (C) 2009 Rob Cash
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * LocalFileMessageStoreLocation.java
 * 
 * Created on Jan 17, 2009 at 8:49:51 AM
 */

package org.robcash.apps.messagepopup.vo.impl;

import java.io.File;
import org.robcash.apps.messagepopup.vo.MessageStoreLocation;

/**
 * Location of a local file message store
 * @author Rob
 */
public class LocalFileMessageStoreLocation implements MessageStoreLocation {

    /**
     * Local file
     */
    private File localFile;

    /**
     * Create a new local file message store location
     */
    public LocalFileMessageStoreLocation() {}

    /**
     * Create a new local file message store location
     * @param localFile Local file where the message store is located
     */
    public LocalFileMessageStoreLocation(File localFile) {
        this.localFile = localFile;
    }

    /**
     * Get the local file where the message store is located
     * @return Local file where the message store is located
     */
    public File getLocalFile() {
        return localFile;
    }

    /**
     * Get the local file where a message store is located
     * @param localFile Local file where a message store is located
     */
    public void setLocalFile(File localFile) {
        this.localFile = localFile;
    }

    @Override
    public String toString() {
        if ( localFile != null ) {
            return localFile.getAbsolutePath();
        }
        else {
            return "";
        }
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final LocalFileMessageStoreLocation other = (LocalFileMessageStoreLocation) obj;
        if (this.localFile != other.localFile && (this.localFile == null || !this.localFile.equals(other.localFile))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 83 * hash + (this.localFile != null ? this.localFile.hashCode() : 0);
        return hash;
    }

}
